home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the 3D Game Programming Gurus / gurus.iso / DirectX / dx9sdkcp.exe / SDK (C++) / Bin / DXUtils / Visual Studio 6.0 Wizards / Source Code / DXAw.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2002-11-12  |  4.5 KB  |  158 lines

  1. // DXaw.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "DxAppWiz.h"
  6. #include "DXaw.h"
  7. #include "chooser.h"
  8.  
  9. #include <atlbase.h>
  10. #include <initguid.h>
  11. #include <ObjModel\bldauto.h>
  12. #include <ObjModel\bldguid.h>
  13. #include <ObjModel\blddefs.h>
  14.  
  15. #ifdef _PSEUDO_DEBUG
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19.  
  20. // This is called immediately after the custom AppWizard is loaded.  Initialize
  21. //  the state of the custom AppWizard here.
  22. void CDirectXAppWiz::InitCustomAppWiz()
  23. {
  24.     // Create a new dialog chooser; CDialogChooser's constructor initializes
  25.     //  its internal array with pointers to the steps.
  26.     m_pChooser = new CDialogChooser;
  27.  
  28.     // Set the maximum number of steps.
  29.     SetNumberOfSteps(-1);
  30.  
  31.     // TODO: Add any other custom AppWizard-wide initialization here.
  32. }
  33.  
  34. // This is called just before the custom AppWizard is unloaded.
  35. void CDirectXAppWiz::ExitCustomAppWiz()
  36. {
  37.     // Deallocate memory used for the dialog chooser
  38.     ASSERT(m_pChooser != NULL);
  39.     delete m_pChooser;
  40.     m_pChooser = NULL;
  41.  
  42.     // TODO: Add code here to deallocate resources used by the custom AppWizard
  43. }
  44.  
  45. // This is called when the user clicks "Create..." on the New Project dialog
  46. //  or "Next" on one of the custom AppWizard's steps.
  47. CAppWizStepDlg* CDirectXAppWiz::Next(CAppWizStepDlg* pDlg)
  48. {
  49.     // Delegate to the dialog chooser
  50.     return m_pChooser->Next(pDlg);
  51. }
  52.  
  53. // This is called when the user clicks "Back" on one of the custom
  54. //  AppWizard's steps.
  55. CAppWizStepDlg* CDirectXAppWiz::Back(CAppWizStepDlg* pDlg)
  56. {
  57.     // Delegate to the dialog chooser
  58.     return m_pChooser->Back(pDlg);
  59. }
  60.  
  61. void CDirectXAppWiz::CustomizeProject(IBuildProject* pProject)
  62. {
  63.     HRESULT hr;
  64.     int i;
  65.  
  66.     IConfigurations* pConfigs = NULL;
  67.     IConfiguration* pConfig   = NULL;
  68.  
  69.     if( pProject == NULL )
  70.         return;
  71.  
  72.     hr = pProject->get_Configurations( &pConfigs );
  73.     if( FAILED(hr) || pConfigs == NULL )
  74.         goto LCleanup;
  75.  
  76.     LONG lCount;
  77.  
  78.     hr = pConfigs->get_Count( &lCount );
  79.     if( FAILED(hr) )
  80.         goto LCleanup;
  81.  
  82.     for( i=1; i<lCount+1; i++ )
  83.     {
  84.         VARIANT var;
  85.         ZeroMemory( &var, sizeof(var) ); 
  86.         var.vt   = VT_I4;
  87.         var.lVal = i;
  88.  
  89.         hr = pConfigs->Item( var, &pConfig );
  90.         if( FAILED(hr) || pConfigs == NULL )
  91.             goto LCleanup;
  92.  
  93.         // Add all libs
  94.         BSTR bstrTool = SysAllocString( L"link.exe" );
  95.         BSTR bstrSettings = SysAllocString( L"dsound.lib dinput8.lib dxerr9.lib d3dx9.lib d3d9.lib d3dxof.lib dxguid.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comctl32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib" );
  96.         hr = pConfig->AddToolSettings( bstrTool, bstrSettings, var );
  97.         SysFreeString( bstrTool );
  98.         SysFreeString( bstrSettings );
  99.  
  100.         // Set MFC or not
  101.         bstrTool = SysAllocString( L"mfc" );
  102.         if( m_pChooser->m_bUseMFC )
  103.             bstrSettings = SysAllocString( L"2" );
  104.         else
  105.             bstrSettings = SysAllocString( L"0" );
  106.         hr = pConfig->AddToolSettings( bstrTool, bstrSettings, var );
  107.         SysFreeString( bstrTool );
  108.         SysFreeString( bstrSettings );
  109.  
  110.         // Add _WIN32_DCOM if using DPlay
  111.         if( m_pChooser->m_bDirectPlay )
  112.         {
  113.             bstrTool = SysAllocString( L"cl.exe" );
  114.             bstrSettings = SysAllocString( L"/D_WIN32_DCOM" );
  115.             hr = pConfig->AddToolSettings( bstrTool, bstrSettings, var );
  116.             SysFreeString( bstrSettings );
  117.             SysFreeString( bstrTool );
  118.         }
  119.  
  120.  
  121.         bstrTool = SysAllocString( L"cl.exe" );
  122.         bstrSettings = SysAllocString( L"/W4" );
  123.         hr = pConfig->AddToolSettings( bstrTool, bstrSettings, var );
  124.         SysFreeString( bstrSettings );
  125.         SysFreeString( bstrTool );
  126.  
  127.         pConfig->Release();
  128.         pConfig = NULL;
  129.  
  130.         if( FAILED(hr) )
  131.             goto LCleanup;
  132.     }
  133.  
  134. LCleanup:
  135.     if( pConfigs )
  136.         pConfigs->Release();
  137.  
  138.     if( pConfig )
  139.         pConfig->Release();
  140.  
  141.     if( FAILED(hr) )
  142.     {
  143.         MessageBox( NULL, "Failed setting Project config", "Failure", MB_OK );
  144.     }
  145. }
  146.  
  147. void CDirectXAppWiz::ProcessTemplate( LPCTSTR lpszInput, DWORD dwSize, OutputStream* pOutput )
  148. {
  149.     CCustomAppWiz::ProcessTemplate( lpszInput, dwSize, pOutput );
  150. }
  151.  
  152. // Here we define one instance of the CDirectXAppWiz class.  You can access
  153. //  m_Dictionary and any other public members of this class through the
  154. //  global DirectXaw.
  155. CDirectXAppWiz DirectXaw;
  156.  
  157.  
  158.